package com.cwnu.mapper;

import com.cwnu.entity.Comment;
import com.cwnu.entity.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CommentMapper {

    @Delete("delete from comment where id = #{id}")
    void deleteComment(Integer id);

    @Insert("insert into comment(article_id, create_id, content, create_time) values(#{articleId}, #{createId}, #{content}, now());")
    void createComment(Integer articleId, String content, Integer createId);

    @Select("select * from comment where article_id = #{articleId}")
    List<Comment> getCommentsByArticleId(Integer articleId);

    @Select("select * from user where id = #{id}")
    User getUserByUserId(Integer id);
}
